#!usr/bin/python
# -*= coding: UTF-8 -*-
import re
a = re.search(r'python(C|D)', 'pythonC')  #表示匹配正则表达式PythonC或pythonD
print('a1', a)

a = re.search(r'python(C|D)', 'pythonD')  #
print('a2', a)

a = re.search(r'^pythonC', 'pythonC.com')  #匹配pythonC开头的字符串
print('a3', a)

a = re.search(r'^pythonC$', 'pythonC.com')  #匹配pythonC结尾的字符串，匹配不上
print('a4', a)

a = re.search(r'pythonC$', 'lovepythonC')  #匹配pythonC
print('a5', a)

a = re.search(r'(pythonC)', 'lovepythonC')  #匹配pythonC
print('a6', a)

a = re.search(r'(pythonC)\1', 'pythonC.com')  #匹配pythonCpythonC,表示从1开始的第一个子字符串pythonC，匹配不上
print('a7', a)

a = re.search(r'(pythonC)\1', 'pythonCpythonC')  #匹配pythonCpythonC,表示从1开始的第一个子字符串pythonC，匹配上
print('a8', a)

a = re.search(r'(pythonC)\060', 'pythonCpythonC8')  #匹配pythonC后面8进制的60,ascII妈
print('a9', a)

a = re.search(r'(pythonC)\060', 'pythonCpythonC0')  #匹配pythonC后面16进制的30 = 8进制的60
print('a10', a)

a = re.search(r'(pythonC)\141', 'pythonCpythonCa')  #匹配pythonC后面ascii码 小写a的ASCII码是97，转换为8进制的141
print('a100', a)

a = re.search(r'.', 'pythonC0')  #匹配除下划线外 的任何字符
print('a11', a)

a = re.findall(r'[a-z]', 'pythonC.com')  #匹配除下划线外 的任何字符
print('a12', a)

a = re.search(r'\.', 'pythonC0')  #匹配一个点，找不到
print('a12', a)

a = re.search(r'[.]', 'pythonC0')  #匹配一个点，找不到
print('a13', a)

a = re.search(r'[\n]', 'pythonC0\n')  #匹配回车符
print('a14', a)

a = re.search(r'[^a-z]', 'PythonC.com\n')  #匹配回车符
print('a15', a)

a = re.findall(r'[^a-z]', 'PythonC.com\n')  #匹配托字符取反
print('a16', a)

a = re.findall(r'[a-z^]', 'PythonC.com\n')  #匹配托字符本身
print('a17', a)

a = re.findall(r'[a-z^]', 'PythonC.com\n^')  #匹配托字符本身
print('a18', a)

a = re.findall(r'PythonC{3}', 'PythonCCCCCC')  #匹配托字符本身
print('a19', a)

a = re.findall(r'(PythonC){3}', 'PythonCPythonCPythonC')  #匹配托字符本身
print('a20', a)

a = re.search(r'(PythonC){3}', 'PythonCPythonCPythonC')  #匹配PythonC3次
print('a21', a)

a = re.search(r'(PythonC){1,5}', 'PythonCPythonCPythonCPythonC')  #匹配PythonC一次至五次,注意，正则里面不能随便加空格！
print('a22', a)

s = '<html><title>I love python.com</title></html>'
a = re.search(r"<.+>", s)
print('a23', a)  #贪婪，尽可能的匹配多个，匹配了整个字符串

a = re.search(r"<.+?>", s)
print('a24', a)  #非贪婪，匹配了整个字符串



















